<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<link rel="stylesheet" href="hr.css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
</head>
<body>

<?php 
require "hrfuns.php";
$db = GetDB();

if (isset($_POST["txtSQL"])) {
    $db = GetDB(); 
    $sqlstr = $_POST["txtSQL"];
    $result = $db->query($sqlstr);

    if ($result) {
        echo "<table border=1 cellspacing=1 cellpadding=2>\n";
        echo "<tr>\n";
        for ($i=0; $i<$result->numColumns(); $i++) 
            echo "<th>" . $result->columnName($i) . "</th>";
        echo "</tr>\n";

        while ($row = $result->fetchArray(SQLITE3_NUM)) {
            echo "<tr>\n";
            foreach ($row as $field)
                echo "<td>$field</td>";
            echo "\n";
            echo "</tr>\n";
        }
        echo "</table>\n";
    }
    else  {
       echo "Error running statement: $sqlstr";
    }
    $db->close();
}
else {
    echo "Empty";
}
?>
</body>
</html>
